﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebChatClient
{
    public class Helper : System.Web.Services.WebService
    {
        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }

        [WebMethod]
        public bool SaveFile(string fileName, byte[]fileData)
        {
            try
            {
                string path = Path.GetFullPath(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "App_Data/Files/"));
                FileStream f = new FileStream(path+fileName, FileMode.Create, FileAccess.Write);

                f.Write(fileData, 0, fileData.Length);

                f.Close();
                return true;
            }
            catch (Exception _Exception)
            {
                // Error
                return false;
            }
            return false;

        }
    }
}